const express = require("express");
const router = express.Router();
const models = require("../models");
const Op = models.Sequelize.Op; // 模糊查询的时候需要用到

// 查询社团类型列表
router.get("/list", async function (req, res, next) {
  const where = {};
  const result = await models.SocietyType.findAndCountAll({
    where: where,
  });
  res.json({
    code: 200,
    msg: "操作成功",
    data: result.rows,
  });
});

// 修改社团类型
router.put("/", async function (req, res, next) {
  const result = await models.SocietyType.findByPk(req.body.id);
  result.update(req.body);
  res.json({
    code: 200,
    msg: "操作成功",
  });
});

module.exports = router;
